package org.aldar.bquest.screens;

import org.aldar.bquest.util.ExceptionUtil;
import org.aldar.bquest.util.SQLiteHelper;
import org.andengine.engine.options.EngineOptions;
import org.andengine.entity.scene.Scene;
import org.andengine.ui.activity.SimpleBaseGameActivity;

import java.io.IOException;

/**
 * User: Daria
 * Date: 12/6/14 3:37 PM
 */
public abstract class LoggedSimpleBaseGameActivity extends SimpleBaseGameActivity {
    @Override
    protected final void onCreateResources() throws IOException {
        try {
            onMyCreateResources();
        } catch (Throwable t) {
            ExceptionUtil.logThrowable(t, this, getSqLiteHelper());
        }
    }

    @Override
    protected final Scene onCreateScene() {
        try {
            return onMyCreateScene();
        } catch (Throwable t) {
            ExceptionUtil.logThrowable(t, this, getSqLiteHelper());
        }
        return null;
    }

    @Override
    public final EngineOptions onCreateEngineOptions() {
        try {
            return onMyCreateEngineOptions();
        } catch (Throwable t) {
            ExceptionUtil.logThrowable(t, this, getSqLiteHelper());
        }
        return null;
    }

    protected abstract void onMyCreateResources() throws IOException;

    protected abstract Scene onMyCreateScene();

    protected abstract EngineOptions onMyCreateEngineOptions();

    protected abstract SQLiteHelper getSqLiteHelper();

    @Override
    public synchronized void onResumeGame() {
        //To change body of overridden methods use File | Settings | File Templates.
        try {
            super.onResumeGame();
        } catch (Throwable t) {
            ExceptionUtil.logThrowable(t, this, getSqLiteHelper());
        }
    }

    @Override
    public synchronized void onResume() {
        //To change body of overridden methods use File | Settings | File Templates.
        try {
            super.onResume();
        } catch (Throwable t) {
            ExceptionUtil.logThrowable(t, this, getSqLiteHelper());
        }
    }


}
